<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en">
<HEAD>

<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
Commands
</TITLE>

<link rel="stylesheet" type="text/css" HREF="../book.css">
</HEAD>
<BODY BGCOLOR="#ffffff">
<h3>Commands</h3>


<p>A <b>command</b> is the declaration of a behaviour by <b>id</b>.
Commands are used to declare semantic behaviour so that action implementations defined
elsewhere by handlers. The separation of the command from the behaviour
implementation allows multiple plug-ins to define implementations that implement the
same semantic command. The command is what gets associated with a
particular key binding.</p>


<p>The workbench defines many common commands in its <b>plugin.xml</b>
file, and plug-ins are encouraged to associate their own implementations with these
commands where it makes sense. In this way, semantically similar
behaviour implemented in different plug-ins may share the same key binding.</p>


<h4>Defining a command</h4>


<p>Commands are defined using the <b><a href="../reference/extension-points/org_eclipse_ui_commands.html">org.eclipse.ui.commands</a></b>
extension point. The following comes from the Info example markup:</p>


<pre>
&lt;extension
	point=&quot;org.eclipse.ui.commands&quot;&gt;
	...
      &lt;command
            categoryId=&quot;org.eclipse.ui.examples.contributions.commands.category&quot;
            id=&quot;org.eclipse.ui.examples.contributions.view.count&quot;
            description=&quot;%contributions.view.count.desc&quot;
            name=&quot;%contributions.view.count.name&quot;&gt;
      &lt;/command&gt;
	...
</pre>


<p>The command definition specifies a <b>name</b>, <b>description</b>, and <b>id</b> for
the behaviour. It also specifies the id of a category for the command, which is
used to group commands in the preferences dialog.&nbsp; The categories are also
defined in the <b><a href="../reference/extension-points/org_eclipse_ui_commands.html">org.eclipse.ui.commands</a>
</b>
extension point:</p>
<pre>
      ...
      &lt;category
            name=&quot;%contributions.commands.category.name&quot;
            description=&quot;%contributions.commands.category.desc&quot;
            id=&quot;org.eclipse.ui.examples.contributions.commands.category&quot;&gt;
      &lt;/category&gt;
      ...
</pre>

<p>Note that there is no implementation specified for a
command. A command only becomes concrete when a plug-in
associates its handler or action with the command id.  We'll
talk about the different ways to associate handler implementations
with commands in the
<a href="workbench_cmd_handlers.htm" 
class="XRef">org.eclipse.ui.handlers</a> section.  We'll talk about
binding key sequences to commands in the <a href="workbench_cmd_bindings.htm" 
class="XRef">org.eclipse.ui.bindings</a> section.
</p>



</BODY>
</HTML>
